#!/bin/bash

# 家庭图书管理系统 - 开发环境检查脚本

echo "========================================="
echo "  家庭图书管理系统 - 开发环境检查"
echo "========================================="

# 检查Java环境
echo "检查Java环境..."
if command -v java &> /dev/null; then
    JAVA_VERSION=$(java -version 2>&1 | head -1)
    echo "✓ Java已安装: $JAVA_VERSION"
else
    echo "✗ 未检测到Java环境"
fi

# 检查Maven环境
echo "检查Maven环境..."
if command -v mvn &> /dev/null; then
    MAVEN_VERSION=$(mvn -v | head -1)
    echo "✓ Maven已安装: $MAVEN_VERSION"
else
    echo "✗ 未检测到Maven环境"
fi

# 检查Node.js环境
echo "检查Node.js环境..."
if command -v node &> /dev/null; then
    NODE_VERSION=$(node --version)
    echo "✓ Node.js已安装: $NODE_VERSION"
else
    echo "✗ 未检测到Node.js环境"
fi

# 检查Docker环境
echo "检查Docker环境..."
if command -v docker &> /dev/null; then
    DOCKER_VERSION=$(docker --version)
    echo "✓ Docker已安装: $DOCKER_VERSION"
else
    echo "✗ 未检测到Docker环境"
fi

# 检查Docker Compose环境
echo "检查Docker Compose环境..."
if command -v docker-compose &> /dev/null; then
    DOCKER_COMPOSE_VERSION=$(docker-compose --version)
    echo "✓ Docker Compose已安装: $DOCKER_COMPOSE_VERSION"
else
    echo "✗ 未检测到Docker Compose环境"
fi

# 检查项目结构
echo "检查项目结构..."
if [ -d "../src/main/java/com/example/familylibrary" ]; then
    echo "✓ 后端项目结构完整"
else
    echo "✗ 后端项目结构缺失"
fi

if [ -d "../frontend/h5-mobile" ]; then
    echo "✓ H5移动端项目存在"
else
    echo "✗ H5移动端项目缺失"
fi

if [ -d "../frontend/web-admin" ]; then
    echo "✓ Web管理端项目存在"
else
    echo "✗ Web管理端项目缺失"
fi

# 检查配置文件
echo "检查配置文件..."
if [ -f "../pom.xml" ]; then
    echo "✓ Maven配置文件存在"
else
    echo "✗ Maven配置文件缺失"
fi

if [ -f "../src/main/resources/application.yml" ]; then
    echo "✓ Spring Boot配置文件存在"
else
    echo "✗ Spring Boot配置文件缺失"
fi

# 检查前端依赖
echo "检查前端依赖..."
if [ -f "../frontend/h5-mobile/package.json" ]; then
    echo "✓ H5移动端package.json存在"
else
    echo "✗ H5移动端package.json缺失"
fi

if [ -f "../frontend/web-admin/package.json" ]; then
    echo "✓ Web管理端package.json存在"
else
    echo "✗ Web管理端package.json缺失"
fi

echo ""
echo "========================================="
echo "  开发环境检查完成"
echo "========================================="